package org.example.petitionplatformsystem.service.Impl;

import org.example.petitionplatformsystem.dao.LeaderMailboxRepository;
import org.example.petitionplatformsystem.dao.model.LeaderMailbox;
import org.example.petitionplatformsystem.service.LeaderMailboxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LeaderMailboxServiceImpl implements LeaderMailboxService {
    @Autowired
    private LeaderMailboxRepository leaderMailboxRepository;

    @Override
    public LeaderMailbox addLeaderMailbox(LeaderMailbox leaderMailbox) {
        return  leaderMailboxRepository.save(leaderMailbox);
    }

    @Override
    public void updateLeaderMailbox(LeaderMailbox leaderMailbox) {
        leaderMailboxRepository.save(leaderMailbox);
    }

    @Override
    public void deleteLeaderMailbox(LeaderMailbox leaderMailbox) {
        leaderMailboxRepository.delete(leaderMailbox);
    }

    @Override
    public LeaderMailbox getLeaderMailboxById(long id) {
        return leaderMailboxRepository.findById(id).orElse(null);
    }

    @Override
    public List<LeaderMailbox> getAllLeaderMailboxes() {
        return leaderMailboxRepository.findAll();
    }

    @Override
    public List<LeaderMailbox> getAllLeaderMailboxesByUserId(long userId) {
        return leaderMailboxRepository.findByUserID(userId);
    }


}
